<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head data-th-replace="admin/common/head"></head>
<body>
<!-- Navigation -->
<th:block data-th-replace="admin/common/navigation"></th:block>
<div id="page-wrapper">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">货单管理</h1>
        </div>
        <!-- /.col-lg-12 -->
    </div>

    <div class="row">
        <div class="col-lg-3 col-md-6">
            <div class="panel panel-yellow">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-shopping-cart fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div class="huge" th:text="${stayCount}">100</div>
                            <div>待发货</div>
                        </div>
                    </div>
                </div>
                <a href="/campusadmin/ordermanage/?status=1">
                    <div class="panel-footer">
                        <span class="pull-left">查看</span>
                        <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                        <div class="clearfix"></div>
                    </div>
                </a>
            </div>
        </div>

        <div class="col-lg-3 col-md-6">
            <div class="panel panel-green">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-tasks fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div class="huge" th:text="${sentCount}">12</div>
                            <div>已发货</div>
                        </div>
                    </div>
                </div>
                <a href="/campusadmin/ordermanage/?status=2">
                    <div class="panel-footer">
                        <span class="pull-left">查看</span>
                        <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                        <div class="clearfix"></div>
                    </div>
                </a>
            </div>
        </div>

        <div class="col-lg-3 col-md-6">
            <div class="panel panel-red">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-support fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div class="huge" th:text="${backCount}">13</div>
                            <div>正在退货</div>
                        </div>
                    </div>
                </div>
                <a href="/campusadmin/ordermanage/?status=3">
                    <div class="panel-footer">
                        <span class="pull-left">查看</span>
                        <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                        <div class="clearfix"></div>
                    </div>
                </a>
            </div>
        </div>



        <div class="col-lg-3 col-md-6">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-comments fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div class="huge" th:text="${totalCount}">26</div>
                            <div>所有货单</div>
                        </div>
                    </div>
                </div>
                <a href="/campusadmin/ordermanage/">
                    <div class="panel-footer">
                        <span class="pull-left">查看</span>
                        <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                        <div class="clearfix"></div>
                    </div>
                </a>
            </div>
        </div>


    </div>

    <div class="row">
        <div class="col-lg-12">
            <form th:action="@{'/campusadmin/ordermanage/'}"  role="form">
                <label>货单号</label>
                <input type="text" name="id" th:value="${id}" placeholder="货单号"/>
                <button class="btn btn-primary">搜索</button>
            </form>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <hr/>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <table class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th>#</th>
                    <th>货单号</th>
                    <th>货物名称</th>
                    <th>货物数量</th>
                    <th>货物单价</th>
                    <th>货物总价</th>
                    <th>买家学号</th>
                    <th>买家姓名</th>
                    <th>买家电话</th>
                    <th>卖家学号</th>
                    <th>卖家姓名</th>
                    <th>卖家电话</th>
                    <th>货单创建时间</th>
                    <th>货单状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="order,iterStatus:${orders}">
                    <td th:text="${iterStatus.count}">1</td>
                    <td th:text="${order.id}">订单号</td>
                    <td th:text="${order.product.name}">货物名称</td>
                    <td th:text="${order.orderProduct.productNum}">货物数量</td>
                    <td th:text="${order.orderProduct.price}">货物单价</td>
                    <td th:text="${order.totalPrice}">货物总价</td>
                    <td th:text="${order.buyer.studentNumber}">买家学号</td>
                    <td th:text="${order.buyer.name}">买家姓名</td>
                    <td th:text="${order.buyer.mobile}">买家电话</td>
                    <td th:text="${order.seller.studentNumber}">卖家学号</td>
                    <td th:text="${order.seller.name}">卖家姓名</td>
                    <td th:text="${order.seller.mobile}">卖家电话</td>
                    <td th:text="${#dates.format(order.createTime, 'yyyy-MMM-dd hh:mm:ss')}">货单创建时间</td>
                    <td>
                        <th:block th:if="${order.status} eq 1">
                            待发货
                        </th:block>
                        <th:block th:if="${order.status} eq 2">
                            已发货
                        </th:block>
                        <th:block th:if="${order.status} eq 3">
                            退货中
                        </th:block>
                        <th:block th:if="${order.status} eq 4">
                            已退货
                        </th:block>
                        <th:block th:if="${order.status} eq 5">
                            已完成
                        </th:block>
                    </td>
                    <td>
                        <th:block th:if="${order.status} eq 1">
                            <a th:href="@{'/campusadmin/ordermanage/changeStatus/'+${order.id}+'/send'}" class="btn btn-primary">发货</a>
                        </th:block>
                        <th:block th:if="${order.status} eq 2">
                            <a th:href="@{'/campusadmin/ordermanage/changeStatus/'+${order.id}+'/finish'}" class="btn btn-primary">完成订单</a>
                            <a th:href="@{'/campusadmin/ordermanage/changeStatus/'+${order.id}+'/back'}" class="btn btn-warning">退货</a>
                        </th:block>
                        <th:block th:if="${order.status} eq 3">
                            <a th:href="@{'/campusadmin/ordermanage/changeStatus/'+${order.id}+'/finish'}" class="btn btn-info">完成订单</a>
                            <a th:href="@{'/campusadmin/ordermanage/changeStatus/'+${order.id}+'/finishBack'}" class="btn btn-primary">完成退货</a>
                            <a th:href="@{'/campusadmin/ordermanage/changeStatus/'+${order.id}+'/cancelBack'}" class="btn btn-warning">撤销退货</a>
                        </th:block>
                        <th:block th:if="${order.status} eq 4">
                            <a th:href="@{'/campusadmin/ordermanage/changeStatus/'+${order.id}+'/recover'}" class="btn btn-primary">恢复最初状态</a>
                        </th:block>
                        <th:block th:if="${order.status} eq 5">
                            <a th:href="@{'/campusadmin/ordermanage/changeStatus/'+${order.id}+'/recover'}" class="btn btn-primary">恢复最初状态</a>
                        </th:block>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <!-- /.row -->
    <!--page begin-->
    <nav data-th-replace="common/pager"></nav>
    <!--page end -->
</div>
<!-- /#page-wrapper -->

<!-- Scripts -->
<th:block data-th-replace="admin/common/scripts"></th:block>
</body>
</html>